import { createApp } from 'vue';
import App from './App.vue';
import { setupStore } from '@/store';
import { router, setupRouter } from '@/router';
import { setupRouterGuard } from '@/router/guard';
import { Interceptors } from '@/http/interceptor';
import { useInstallApp } from '@/hooks/use-app';
import {
	registerCommonComp,
	registerPageComp,
	registerDirective,
	registerUserComp,
} from '@/register';
import { setupI18N } from '@/locales';
if (import.meta.env.DEV) {
	import('ant-design-vue/dist/antd.less');
}
import 'font-awesome/css/font-awesome.css';
import '@/styles/index.less';
import less from 'less'; //根据配置文件更改颜色变量需要引用less，不然window.less为undefined;
import VueAMap from 'vue-amap';
import AMapLoader from '@amap/amap-jsapi-loader';
AMapLoader.load({
	key: '6ab2751103aea67e817c90a5528181b5',
	version: '2.0',
	plugins: ['AMap.Geolocation', 'AMap.PlaceSearch', 'AMap.Geocoder'],
});
async function bootstrap() {
	const app = createApp(App);
	if (import.meta.env.DEV) {
		const Antd = await import('ant-design-vue');
		app.use(Antd);
	}
	//挂载地图
	app.use(VueAMap);
	//挂载less
	app.use(less);
	//  安装应用
	useInstallApp();
	//  设置国际化
	await setupI18N(app);
	//  配置store
	setupStore(app);
	//  设置路由
	setupRouter(app);
	//  设置路由守卫
	setupRouterGuard(router);
	//  设置拦截器
	Interceptors.getInstance(router);
	// 组件注册
	registerCommonComp(app);
	registerUserComp(app);
	registerPageComp(app);
	registerDirective(app);
	app.mount('#app');
}

bootstrap();
